<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>{:C('SYSTEM_NAME')}- 用户登录</title>

        <include file="Common:head" />
        <link rel="stylesheet" type="text/css" href="__STATIC__/css/login.css" />
    </head>
    <body>
        <div class="top">
            <form name="userLoginActionForm" id="userLoginActionForm"
                  method="POST" action="" target="_parent" >
                <input type="text" autofocus="true" id="username"
                       name="username" value="账户" autocomplete="off" maxlength="60"
                       onblur="userInter(2)"  />

                <input type="text" id="p_t" name="p_t" value="密码" onfocus="hide_pw()" autocomplete="off"/>
                <input type="password" id="password" name="password" maxlength="60" onblur="check_pw();" />
                <input type="text" id="code" name="code" value="验证码" maxlength="20" 
                       onfocus="check_yzm(1)" onblur="check_yzm(2);" autocomplete="off"/>
                <a href="javaScript:changeCode()" title="点击，换一张！">
                    <img src="{:U('Index/code?code_len=4&font_size=14&width=100&height=28&code='.time())}"
                         id="vcodesrc" name="vcodesrc"
                         border="0" width="116" height="38"
                         style="float:left;display:none" alt="点击，换一张！"  />
                </a>
                <input type="button" value="" id="login_bt" name="login_bt" onclick="login()"/>
                <!--    <a href="" class="forget">忘记密码？</a> -->
            </form>
        </div>
        <div class="bottom">

            <div class="item_list">
                <ul>
                    <li>一、系统上线</li>
                </ul>
            </div>

        </div> 
        <!--<div style="text-align:center;" class="register_bottom"><a>版权：科技有限公司</a></div>-->
        <script type="text/javascript">
            function userInter(val) {
                if (val == 1) {
                    if ($("#username").val() == "账户") {
                        $("#username").val("");
                    }
                } else {
                    if ($("#username").val() == "") {
                        $("#username").val("账户");
                    }
                }
            }
            $(function () {
                $('input:text:first').focus(function () {
                    userInter(1);
                });
                userInter(1);
                $('form').keyup(function (event) {
                    if (event.keyCode == 13) {
                        login();
                    }
                });
            })
            var hide_pw = function () {
                $("#p_t").hide();
                $("#password").show();
                $("#password").focus();
            }
            var check_pw = function () {
                if ($("#password").val() == "") {
                    $("#p_t").show();
                    $("#password").hide();
                }
            }

            var check_yzm = function (val) {
                if (val == 1) {
                    if ($("#code").val() == "验证码") {
                        $("#code").val("");
                    }
                    $("#vcodesrc").show();
                } else {
                    if ($("#code").val() == "" || $("#code").val() == "验证码") {
                        $("#code").val("验证码");
                    }
                }
            }

            var changeCode = function () {
                var that = document.getElementById('vcodesrc');
                that.src = that.src + '&' + Math.random();
            }

            var login = function () {
                if (!$('#username').val()) {
                    $.messager.alert('提示信息', '请填写用户名', 'error', 'modal-info');
                    return false;
                }
                if (!$('#password').val()) {
                    $.messager.alert('提示信息', '请填写密码', 'error', 'modal-info');
                    return false;
                }
                if (!$('#code').val()) {
                    $.messager.alert('提示信息', '请填写验证码', 'error', 'modal-info');
                    return false;
                }
                $.post("{:U('Index/login?dosubmit=1')}", $("form").serialize(), function (data) {
                    if (!data.status) {
                        $.messager.alert('提示信息', data.info, 'error', 'modal-info');
                        changeCode();
                    } else {
                        window.location.href = data.url;
                    }
                }, 'json');
                return false;
            }
        </script>
    </body>
</html>